<?php

class Ext_User_Action_OAuth_ShowForm_Result
{
    const SUCCESS                        			    =  1;
    const NOTHING                        			    =  0;
    const FAILURE     			                        = -1;
    const FAILURE_USERNAME_MUST_BE_SET     			    = -2;
    const FAILURE_USERNAME_FORMART_ERROR     	        = -3;
    const FAILURE_USERNAME_CONTAIN_DENIED_WORD          = -4;
    const FAILURE_USERNAME_EXISTS     			        = -5;
    const FAILURE_EMAIL_MUST_BE_SET     		        = -6;
    const FAILURE_EMAIL_FORMAT_ERROR     		        = -7;
    const FAILURE_EMAIL_IS_DENIED     			        = -8;
    const FAILURE_EMAIL_ALREADY_USED     		        = -9;
    const FAILURE_PASSWORD_MUST_BE_SET     		        = -10;
    const FAILURE_CONFIRM_PASSWORD_NOT_MATCH_PASSWORD   = -11;
    const FAILURE_UNCATEGORIZED     			        = -12;

    protected $_code;
    protected $_identity;
    protected $_messages;

    public function __construct($code, $identity, array $messages = array())
    {
        $code = (int) $code;

        if ($code < self::FAILURE_UNCATEGORIZED) {
            $code = self::FAILURE;
        } elseif ($code > self::SUCCESS ) {
            $code = 1;
        }

        $this->_code     = $code;
        $this->_identity = $identity;
        $this->_messages = $messages;
    }

    public function isValid()
    {
        return ($this->_code > 0) ? true : false;
    }

    public function getCode()
    {
        return $this->_code;
    }
    
    public function getIdentity()
    {
        return $this->_identity;
    }

    public function getMessages()
    {
        return $this->_messages;
    }
}
